package com.qfjy.config;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;

@Configuration
public class RedisConfig {

    @Value("${spring.redis.port}")
    private Integer port;
    @Value("${spring.redis.password}")
    private String password;
    @Value("${spring.redis.host}")
    private String host;

    @Value("${spring.redis.jedis.pool.max-idle}")
    private Integer maxidle;
    @Value("${spring.redis.jedis.pool.max-active}")
    private Integer  maxactive;
    @Value("${spring.redis.jedis.pool.min-idle}")
    private Integer minidle;
    @Bean
    public JedisPool jedisPool(){
        //连接池配置参数
        GenericObjectPoolConfig genericObjectPoolConfig=new GenericObjectPoolConfig();
        genericObjectPoolConfig.setMaxIdle(maxidle);

        JedisPool jedisPool=new JedisPool(genericObjectPoolConfig,host,port,2000,password);
        return jedisPool;
    }
}
